const Websocket = require('ws');
const http = require('http');
const Types = require('../lib/types');
const util = require('../lib/util');

class Controller {
    /**
     * @param {WebSocket} socket 
     * @param {http.IncomingMessage} req 
     * @param {string} processCode 
     */
    constructor(socket, processCode, session) {
        this.socket = socket;
        this.processCode = processCode;
        this.session = new Types.Session(session.isGuest, session.user, session.agent, session.validtime);

        // accessToken过期检查        
        if (this.session.isGuest === false) {
            let now = util.timestamp();
            if (this.session.validtime < now) {
                this.session.isGuest = true;
            }
        }
    }
}

module.exports = Controller;